var i = 1;

function add() {
	i++;
	if(i > 10) {
		alert("最多添加10项");
	} else {
		$("#sub").remove();
		$("#append").append(' <label for="inputEmail3" class="col-sm-2 control-label" style="margin-top: 5px">选项' + i + '：</label> <div class="col-sm-10" style="margin-top: 5px"> <input type="text" class="form-control" id="inputEmail3"  name=' + "" + i + '> </div> </div><div class="form-group  text-center " id="sub" style="margin-top: 5px">  <button onclick="sub()" style="margin-top: 5px" class="btn btn-success radius">确定</button>');
	}
}

$(function(){
    $("#addProblem").validate({
        rules: {
            "mainProblem": {
                required: true
            }, "problemName": {
                required: true
            },"type": {
                required: true
            },"must": {
                required: true
            },"1": {
                required: true
            },
            "2": {
                required: true
            },
            "3": {
                required: true
            },
            "4": {
                required: true
            },
            "5": {
                required: true
            },
            "6": {
                required: true
            },
            "7": {
                required: true
            },
            "8": {
                required: true
            },
            "9": {
                required: true
            },
            "10": {
                required: true
            },
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $(form).ajaxSubmit({
                success: function(data) {
                    if(data.ok){
                        msg('保存成功',1000,function(){
                            parent.location.replace(parent.location.href);
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        msg(data.msg);
                    }
                },
                error:function(){
                    msg('保存失败，服务器异常');
                }
            });
        }
    });
});

$(function(){
    $(".noclass").click(function(){
        $(".removeClass").attr("style","display:none;");//隐藏div
    });
    $(".disClass").click(function () {
        $(".removeClass").attr("style","display:block")
    })

});